#ifndef SOUNDSERVER_H
#define SOUNDSERVER_H

#include <QObject>
#include <QAudioDeviceInfo>
#include <QAudioInput>
#include <QAudioOutput>

#include <QTcpServer>
#include <QTcpSocket>
#include <QHostAddress>
#include <QNetworkInterface>

#include "sendaudio.h"
#include "recvaudio.h"

#define TCPPORT 10023
#define CLIENT_SEND_PORT 10024
#define CLIENT_RECV_PORT 10025
#define SERVER_SEND_PORT 10026
#define SERVER_RECV_PORT 10027
#include <QDebug>
class SoundServer : public QObject
{
    Q_OBJECT

public:
    explicit SoundServer(QObject *parent = nullptr);
    ~SoundServer();

    bool cmp_str(char str[], char substr[])
    {
        if(strlen(str)<strlen(substr))
            return false;
        for(int i=0;i<strlen(substr);i++)
        {
            if(str[i]!=substr[i])
            {
                return false;
            }
        }
        return true;
    }

    void recvMess(char data[]);
    void sendMess(QByteArray data);

public:
    QList<QAudioDeviceInfo> inputDevs;
    QAudioDeviceInfo inputDevInfo;


    QTcpServer  *tcpServer;//监听套接字
    QTcpSocket  *tcpSocket;//通信套接字

    SendAudio serverSend;
    RecvAudio serverRecv;

    QString clientIP;
};

#endif // SOUNDSERVER_H
